export namespace format {
    //格式化分为元
    export const formatPrice = (value: number | undefined): number => {
        if (value == null) {
            return 0
        }
        return value / 100
    }
    /**
     * 解析url参数
     * @param  url  
     */
    export const parseQueryParam = (url: string): any => {
        var params: any = {};
        var arr = url.split("?");
        if (arr.length <= 1) {
            return params;
        }
        arr = arr[1].split("&");
        for (var i = 0, l = arr.length; i < l; i++) {
            var a = arr[i].split("=");
            params[a[0]] = a[1];
        }
        return params;
    }

    export const formatMobile = (mobile?: string) => {
        if (!mobile) {
            return ''
        }
		if(mobile.length<11){
			return mobile;
		}
        return mobile.substring(0, 3) + "****" + mobile.substring(7);
    }
    export const params2query = (params: any): string => {
        let arr: string[] = []
        for (let key in params) {
            if (params[key]) {
                arr.push(key + "=" + params[key])
            }
        }
        return arr.join('&');
    }
}